package com.ddn.controller.room;

import com.ddn.service.room.LeaverService;
import com.ddn.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * --- 天道酬勤 ---
 *
 * @author XieYp
 * @desc
 * @date 2023/1/2
 */
@RestController
@RequestMapping("/leaver")
public class LeaverController {

    @Autowired
    private LeaverService leaverService;

    @RequestMapping("/list")
    public ResultData list(@RequestParam HashMap<String,Object> map) {
        // System.out.println(map );
        ResultData data = leaverService.findAll(map);
        return data;
    }

    @RequestMapping("/add")
    public ResultData add(HashMap<String,Object> map) {
        ResultData data = leaverService.addLeaver(map);
        return data;
    }

    @RequestMapping("/delete")
    public ResultData delete(@RequestParam HashMap<String,Object> map) {
        ResultData data = leaverService.deleteLeaver(map);
        return data;
    }

    @RequestMapping("/update")
    public ResultData update(@RequestParam HashMap<String,Object> map) {
        ResultData data = leaverService.updateLeaver(map);
        return data;
    }

    @RequestMapping("/delete/batch")
    public ResultData deleteBatch(@RequestParam List<Integer> ids) {
        ResultData data = leaverService.deleteBatch(ids);
        return data;
    }
}
